package com.byt.user.api;

import com.byt.common.bean.VersionInfo;
import com.byt.netapi.ApiBase;
import com.byt.netapi.bean.ResponseBean;
import com.byt.netapi.boby.FormBodys;
import com.byt.netapi.observer.BaseObserver;
import com.byt.user.bean.LoginBean;

import java.util.Map;

public final class UserApi extends ApiBase {

    private static volatile UserApi instance = null;
    private UserApiInterface userApiInterface;
    public static final String PAGE = "page";

    private UserApi() {
        super("");
        userApiInterface = retrofit.create(UserApiInterface.class);
    }

    public static UserApi getInstance() {
        if (instance == null) {
            synchronized (UserApi.class) {
                if (instance == null) {
                    instance = new UserApi();
                }
            }
        }
        return instance;
    }

    /**
     * 获取最新版本
     * @param observer
     * @param map
     */
    public void getVersionInfo(BaseObserver<ResponseBean<VersionInfo>> observer, Map<String,Object> map){
        ApiSubscribe(userApiInterface.getVersionInfo(map), observer);
    }

    /**
     * 登录
     * @param observer
     * @param formBody
     */
    public void onLogin(BaseObserver<ResponseBean<LoginBean>> observer, FormBodys formBody){
        ApiSubscribe(userApiInterface.onLogin(formBody), observer);
    }

    /**
     * 验证码登录
     * @param observer
     * @param formBody
     */
    public void onLoginCode(BaseObserver<ResponseBean<LoginBean>> observer, FormBodys formBody){
        ApiSubscribe(userApiInterface.onLoginCode(formBody), observer);
    }

    /**
     * 验证码登录
     * @param observer
     * @param formBody
     */
    public void onRegiest(BaseObserver<ResponseBean<LoginBean>> observer, FormBodys formBody){
        ApiSubscribe(userApiInterface.onRegiest(formBody), observer);
    }



    /**
     * 验证码登录
     * @param observer
     * @param formBody
     */
    public void onGetCode(BaseObserver<ResponseBean<String>> observer, FormBodys formBody){
        ApiSubscribe(userApiInterface.onGetCode(formBody), observer);
    }


}
